<?php

/**
 * Formulaire de connexion 
 */
class ZendTremplin_Form_Connection extends Zend_Form {

    /**
     * Initialise le formulaire de connexion :
     *  - Login
     *  - Mot de passe
     */
    public function init() {
        $this->setMethod('post');
        // On fixe le path de notre decorator
        $this->addElementPrefixPath('ZendTremplin_Decorator', 'ZendTremplin/decorator/', 'decorator');
        
        // Initialisation du champ login
        $login = new Zend_Form_Element_Text('login');
        $login->addFilter('StringTrim')
                ->setRequired(true)
                ->setLabel('Login')
                ->setAttrib('maxLength', 50)
                ->setDecorators(array('Default'));
        $this->addElement($login);

        // Initiation du champ password
        $pwd = new Zend_Form_Element_Password('pwd');
        $pwd->addFilter('StringTrim')
                ->setRequired(true)
                ->setLabel('Password')
                ->setAttrib('maxLength', 10)
                ->setDecorators(array('Default'));
        $validator = new ZendTremplin_Validate_UserAuthentification(array('login' => $login, 'pwd' => $pwd));
        $pwd->addValidator($validator);
        $this->addElement($pwd);

        // Ajout du bouton d'inscription
        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'label' => 'Connect',
        ));
    }

}

